//
//  WiFiViewController.m
//  QRCodeManager
//
//  Created by Cosmin Stirbu on 4/17/13.
//  Copyright (c) 2013 Cosmin Stirbu. All rights reserved.
//

#import "WiFiViewController.h"

@interface WiFiViewController ()

@end

@implementation WiFiViewController

@synthesize qrWifi;

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated {
    _ssidLabel.text = qrWifi.ssid;
    _passwordLabel.text = qrWifi.password;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
    if (indexPath.row == 1) {
        [pasteBoard setString:qrWifi.ssid];
    } else {
        [pasteBoard setString:qrWifi.password];
    }
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [NSString stringWithFormat:@"Wi-Fi (%@)", qrWifi.type];
}

- (void)viewDidUnload {
    _passwordLabel = nil;
    _ssidLabel = nil;
    [super viewDidUnload];
}
@end
